<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目合格证信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var grid = null;
	$(function () {
		initGrid();//grid
		  $("#searchBar").ligerForm();
		    $("#searchBtn").click(function(event) {
		         var form = new liger.get("searchBar");
		         var data = form.getData();
		/*          var vehNoNum = $("#vehNoNum").val();//上牌号码数字
		         var len = vehNoNum.length;
		         if(!NumberUtils.isUnsignedInteger(vehNoNum)||len!=5){
		 			top.$.ligerDialog.SQalert({content: "上牌号后几位必须为长度为5位的数字！",SQ_type: "error"});
		        	 return false;
		         } */
		         for (name in data){
		            grid.setParm(name,data[name]);
		         };
		        grid.reload();
		    });
		
	});
	  function clearBtn(){
		    $("#searchBar").ligerForm();
					var form = new liger.get("searchBar");
					form.setData({
						cstNm:" ",
						mfrNm:" ",
						splNm:" ",
						paySchNo:" ",
						prdMdl:" ",
						vin:" ",
						licDt:" ",
						provAbbrCd:" ",
						character:" ",
						vehNoNum:" "
					 });
			}
	//初始化列表
	function initGrid(){
		var params = {};
		$("#grid").ligerGrid({
	    	url: '<%=path%>/project/prjprdlicinfo/initList.do',
	    	method : 'get',
	    	parms:params,
	        columns: [
	                  { display: '合格证号', name: 'certNo', minWidth: 80 ,align:'left',
	  	            	
	  	            	enabledSort:true},
	            { display: '客户名称', name: 'cstNm', minWidth: 60,align:'left',enabledSort:true},
	            { display: '经销商', name: 'splNm', minWidth: 150,align:'left',enabledSort:true}, 
	            { display: '厂商', name: 'mfrNm', minWidth: 100,align:'left',enabledSort:true}, 
	             { display: '设备名称', name: 'prdNm', minWidth: 80,align:'left',enabledSort:true}, 	
	              { display: '支付表号', name: 'paySchNo', minWidth: 100,enabledSort:true},
	              { display: '型号', name: 'prdMdl', minWidth: 80,align:'left',enabledSort:true}, 	 
	             { display: '车架号', name: 'vin', minWidth: 80,align:'left',enabledSort:true}, 	
	            { display: '上牌时间', name: 'licDt', minWidth: 60,align:'left',render:renderDate, enabledSort:true}, 
	            { display: '上牌状态', name: 'licDt', minWidth: 60,align:'left',
	            	render: function (rowdata, rowindex, value, column) { 
 	            		 var dt = rowdata.licDt==null?" ":rowdata.licDt;
 	            		 var isDel = rowdata.isDel==null?" ":rowdata.isDel;
 	            		var h = '';
 	            		if(dt!=" "){
 	            			if(rowdata.isDel==CommonConstant.C_YN_N_0&&rowdata.audStsCd==FlowConstant.FLOW_CHECK_STATE_PASS){
 	            				h+='<a  href="javascript:detailBtn(';
 	  	                        h+="'"+rowdata.id+"',";
 	  	                        h+="'"+rowdata.dtlId+"'";
 	  	                        h+=')">已上牌</a>'
 	            			}
 	            			if(rowdata.isDel==CommonConstant.C_YN_N_0&&rowdata.audStsCd==FlowConstant.FLOW_CHECK_STATE_NON){
	            				 h+='<a href="javascript:detailBtn(';
	            				 h+="'"+rowdata.id+"',";
 	  	                         h+="'"+rowdata.dtlId+"'";
	   	                         h+=')">未上牌</a>'
	            			}
 	            		} else{
 	            			    h+='未上牌';
 	            			//if(rowdata.isDel==CommonConstant.C_YN_N_0&&rowdata.audStsCd==FlowConstant.FLOW_CHECK_STATE_NON){
 	            				// h='<a href="javascript:detailBtn(';
 	            				// h+="'"+rowdata.id+"',";
  	  	                         //h+="'"+rowdata.dtlId+"'";
 	   	                         //h+=')">未上牌</a>'
 	            			//}
 	            		} 
 	                        return h;
 	            		},
	            	enabledSort:true}, 
	             {
	                display: '操作',
	                isSort: false,
	                width: 80,
	                align:'left',
	                render: function (rowdata, rowindex, value){
	                	  var h="";
	                		  // if(rowdata.licDt&&rowdata.isDel==CommonConstant.C_YN_N_0&&rowdata.audStsCd==FlowConstant.FLOW_CHECK_STATE_NON){
		                        h='<a class="sq-button-hasicon" href="javascript:modifyBtn(';
		                        h+="'"+rowdata.id+"',";
		                        h+="'"+rowdata.dtlId+"'";
		                        h+=')"><i class="sqBtnIco_4"></i>修改</a>';
	                		  // }
	                    return h;
	                }
	            }  
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        allowUnSelectRow: true,
            alternatingRow: true,
	        rownumbers:true,
	        enabledEdit: true,
	        usePagerOnLessPagesize: true,
	    });
		grid = liger.get("grid");
		grid.setHeight(500);
		
	}
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
        var h="￥" + FormatMoney(value)
        return h;
    }

	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	//添加上牌信息
	function addLicInfoBtn(dtlId){
		var callback = function(){
			 grid.reload();
		}
		var detailFlag = false;
		var timestamp=new Date().getTime();
		Add_navTab( 'tab_prj_prd_veh_info_add'+timestamp,'添加上牌信息','<%=path%>/project/prjprdlicinfo/toAddPage.do?detailFlag='+detailFlag+'&&dtlId='+dtlId,callback);
	}
	

	//添加合格证信息
	function addBtn(){
		var callback = function(){
			 grid.reload();
		}
		var selectedRows = grid.getSelectedRows();
		if(selectedRows.length !=1){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
			return;
		}
		var dtlId = selectedRows[0].dtlId;
		var audStsCd = selectedRows[0].audStsCd;
		if(audStsCd==FlowConstant.FLOW_CHECK_STATE_PASS||audStsCd==FlowConstant.FLOW_CHECK_STATE_NON){
			top.$.ligerDialog.SQalert({content: "已经添加过上牌信息！",SQ_type: "error"});
		 }else{
			var detailFlag = false;
			var timestamp=new Date().getTime();
			Add_navTab( 'tab_prj_prd_veh_info_add'+timestamp,'添加上牌信息','<%=path%>/project/prjprdlicinfo/toAddPage.do?detailFlag='+detailFlag+'&&dtlId='+dtlId,callback);
		}

	}
	
	//修改合格证信息
	function modifyBtn(id,dtlId){
		var callback = function(){
			 grid.reload();
		}
		var detailFlag = false;
		Add_navTab( 'tab_prj_prd_veh_info_modify'+id,'修改上牌信息','<%=path%>/project/prjprdlicinfo/toAddPage4Sys.do?detailFlag='+detailFlag+'&&id='+id+'&&dtlId='+dtlId,callback);
	}

	function detailBtn(id,dtlId){
		var detailFlag = true;
		Add_navTab( 'tab_prj_prd_veh_info_detail'+id,'上牌详情','<%=path%>/project/prjprdlicinfo/toAddPage.do?detailFlag='+detailFlag+'&&id='+id+'&&dtlId='+dtlId);
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//删除所选上牌信息
	function removeBtn(id){
		/* var selectedRows = grid.getSelectedRows();
		if(selectedRows.length <1){
			$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warring"});
			return;
		}
		var _ids = [];
		for ( var index in selectedRows) {
			_ids.push(selectedRows[index].id);
		} */
		var _ids = [];
		_ids.push(id);
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/project/prjprdlicinfo/removeByIds.do',
				success:function(msg){
					 if(msg.success == 1){
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
		
	}
</script>

<body class="iframeBody">
	<div class="Wrapper">
           <div id="pageInTab" class="pageInTab">
           <div class="searchArea">
    <form id="searchBar">
   <div class="fieldset1 clearFix">
     <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">客户名称</div>
                <div class="field">
                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">厂商</div>
                <div class="field">
                    <input name="mfrNm" id="mfrNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">供应商</div>
                <div class="field">
                    <input name="splNm" id="splNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">支付表号</div>
                <div class="field">
                    <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">产品型号</div>
                <div class="field">
                    <input name="prdMdl" id="prdMdl" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">车架号</div>
                <div class="field">
                    <input name="vin" id="vin" type="text" class="ui-textbox" value="">
                </div>
            </div>
              <div class="fieldBox col_33" id="searchCstNmId">
                <div class="label">上牌时间</div>
                <div class="field">
                    <input name="licDt" id="licDt" type="text" class="ui-datepicker" value="">
                </div>
            </div>
              <div class="fieldBox col_66" >
                <div class="label">车牌号</div>
                <div class="field">
                 		<select name="provAbbrCd" id="provAbbrCd" data-value=""  >
                 			<option value=""   checked>请选择</option>
								<c:forEach items="${provAbbrCdList }" var="kv">
								    <option value="${kv.key }" >${kv.value }</option>
								</c:forEach>
						</select>
						<select name="character" id="character" data-value="" >
								<option value=""  checked >请选择</option>
								<c:forEach items="${characterList }" var="kv">
								    <option value="${kv.key }" >${kv.value }</option>
								</c:forEach>
						</select>
                    <input name="vehNoNum" id="vehNoNum" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="clearFix"></div>
   <div class="btnsBox">
   			<span id="searchBtn"  class="sq-button sq-button-round">查询</span>
           <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
          <%--<span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round"><!-- <i class="sqBtnIco_5"></i> -->新增</span>--%>
<!--           <span id="removeBtn" onclick="removeBtn();" class="sq-button-round"><i class="sqBtnIco_5"></i>作废</span>
 -->  </div>
</div>
</form>
</div>
<div id="grid" class="sq-grid"></div>

</div>
		</div>
			</div>
</body>
</html>